this.BX=this.BX||{};(function(t,e){"use strict";var s=function t(){babelHelpers.classCallCheck(this,t)};babelHelpers.defineProperty(s,"NONE","ui-progressbar-none");babelHelpers.defineProperty(s,"DANGER","ui-progressbar-danger");babelHelpers.defineProperty(s,"SUCCESS","ui-progressbar-success");babelHelpers.defineProperty(s,"PRIMARY","ui-progressbar-primary");babelHelpers.defineProperty(s,"WARNING","ui-progressbar-warning");var i=function t(){babelHelpers.classCallCheck(this,t)};babelHelpers.defineProperty(i,"MEDIUM","ui-progressbar-md");babelHelpers.defineProperty(i,"LARGE","ui-progressbar-lg");var r=function t(){babelHelpers.classCallCheck(this,t)};babelHelpers.defineProperty(r,"COUNTER","COUNTER");babelHelpers.defineProperty(r,"PERCENT","PERCENT");babelHelpers.defineProperty(r,"NONE","NONE");var a,n,o,l;function u(t,e){h(t,e);e.add(t)}function h(t,e){if(e.has(t)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function c(t,e,s){if(!e.has(t)){throw new TypeError("attempted to get private field on non-instance")}return s}var f=new WeakSet;var p=function(){function t(){var s=arguments.length>0&&arguments[0]!==undefined?arguments[0]:ProgressBarOptions;babelHelpers.classCallCheck(this,t);u(this,f);this.options=e.Type.isPlainObject(s)?s:{};this.value=e.Type.isNumber(this.options.value)?this.options.value:0;this.maxValue=e.Type.isNumber(this.options.maxValue)?this.options.maxValue:100;this.bar=null;this.container=null;this.status=null;this.finished=false;this.fill=e.Type.isBoolean(this.options.fill)?this.options.fill:false;this.column=e.Type.isBoolean(this.options.column)?this.options.column:false;this.statusPercent="0%";this.statusCounter="0 / 0";this.textBefore=e.Type.isString(this.options.textBefore)?this.options.textBefore:null;this.textBeforeContainer=null;this.textAfter=e.Type.isString(this.options.textAfter)?this.options.textAfter:null;this.textAfterContainer=null;this.statusType=e.Type.isString(this.options.statusType)?this.options.statusType:BX.UI.ProgressBar.Status.NONE;this.size=e.Type.isStringFilled(this.options.size)||e.Type.isNumber(this.options.size)?this.options.size:BX.UI.ProgressBar.Size.MEDIUM;this.colorTrack=e.Type.isString(this.options.colorTrack)?this.options.colorTrack:null;this.colorBar=e.Type.isString(this.options.colorBar)?this.options.colorBar:null;this.color=e.Type.isString(this.options.color)?this.options.color:BX.UI.ProgressBar.Color.PRIMARY}babelHelpers.createClass(t,[{key:"setValue",value:function t(s){if(e.Type.isNumber(s)){this.value=s>this.maxValue?this.maxValue:s}return this}},{key:"getValue",value:function t(){return this.value}},{key:"setMaxValue",value:function t(s){if(e.Type.isNumber(s)){this.maxValue=s}return this}},{key:"getMaxValue",value:function t(){return this.maxValue}},{key:"finish",value:function t(){this.update(this.maxValue)}},{key:"isFinish",value:function t(){return this.finished}},{key:"setColor",value:function t(s){if(e.Type.isStringFilled(s)){if(this.container===null){this.createContainer()}e.Dom.removeClass(this.container,this.color);this.color=s;e.Dom.addClass(this.container,this.color)}return this}},{key:"setColorBar",value:function t(s){if(e.Type.isStringFilled(s)){this.colorBar=s;s="--ui-current-bar-color:"+s+";";c(this,f,g).call(this,s)}return this}},{key:"setColorTrack",value:function t(s){if(e.Type.isStringFilled(s)){this.colorTrack=s;this.setFill(true);s="--ui-current-bar-bg-track-color:"+s+";";c(this,f,g).call(this,s)}return this}},{key:"setSize",value:function t(s){if(this.container===null){this.createContainer()}if(e.Type.isStringFilled(s)){e.Dom.removeClass(this.container,this.size);this.size=s;e.Dom.addClass(this.container,this.size)}else if(e.Type.isNumber(s)){this.container.setAttribute("style","--ui-current-bar-size:"+s+"px;");this.size=s}return this}},{key:"setFill",value:function t(s){if(this.container===null){this.createContainer()}if(s){e.Dom.addClass(this.container,"ui-progressbar-bg")}else{e.Dom.removeClass(this.container,"ui-progressbar-bg")}return this}},{key:"setColumn",value:function t(s){if(this.container===null){this.createContainer()}if(s===true){e.Dom.addClass(this.container,"ui-progressbar-column")}else{e.Dom.removeClass(this.container,"ui-progressbar-column")}return this}},{key:"setTextBefore",value:function t(s){if(e.Type.isStringFilled(s)){this.textBefore=s;if(!this.textBeforeContainer){this.createTextBefore(s)}else{e.Dom.adjust(this.textBeforeContainer,{html:s})}}}},{key:"createTextBefore",value:function t(s){if(!this.textBeforeContainer&&e.Type.isStringFilled(s)){this.textBeforeContainer=e.Tag.render(a||(a=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="ui-progressbar-text-before">',"</div>\n\t\t\t"])),s)}}},{key:"getTextBefore",value:function t(){if(!this.textBeforeContainer){this.createTextBefore(this.textBefore)}return this.textBeforeContainer}},{key:"setTextAfter",value:function t(s){if(e.Type.isStringFilled(s)){this.textAfter=s;if(!this.textAfterContainer){this.createTextAfter(s)}else{e.Dom.adjust(this.textAfterContainer,{html:s})}}}},{key:"createTextAfter",value:function t(s){if(!this.textAfterContainer&&e.Type.isStringFilled(s)){this.textAfterContainer=e.Tag.render(n||(n=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="ui-progressbar-text-after">',"</div>\n\t\t\t"])),s)}}},{key:"getTextAfter",value:function t(){if(!this.textAfterContainer){this.createTextAfter(this.textAfter)}return this.textAfterContainer}},{key:"setStatus",value:function t(){if(this.getStatusType()===BX.UI.ProgressBar.Status.COUNTER){e.Dom.adjust(this.status,{text:this.getStatusCounter()})}else if(this.getStatusType()===BX.UI.ProgressBar.Status.PERCENT){e.Dom.adjust(this.status.firstChild,{text:this.getStatusPercent()})}}},{key:"getStatus",value:function t(){if(!this.status){if(this.getStatusType()===BX.UI.ProgressBar.Status.COUNTER){this.status=e.Tag.render(o||(o=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t\t<div class="ui-progressbar-status">',"</div>\n\t\t\t\t"])),this.getStatusCounter())}else if(this.getStatusType()===BX.UI.ProgressBar.Status.PERCENT){this.status=e.Tag.render(l||(l=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t\t<div class="ui-progressbar-status-percent">\n\t\t\t\t\t\t<span class="ui-progressbar-status-percent-value">','</span>\n\t\t\t\t\t\t<span class="ui-progressbar-status-percent-sign">%</span>\n\t\t\t\t\t</div>\n\t\t\t\t'])),this.getStatusPercent())}else{this.status=e.Dom.create("span",{})}}return this.status}},{key:"getStatusPercent",value:function t(){if(this.maxValue===0){return"0%"}this.statusPercent=Math.round(this.getValue()/(this.getMaxValue()/100));if(this.statusPercent>100){this.statusPercent=100}return this.statusPercent}},{key:"getStatusCounter",value:function t(){if(Math.round(this.getValue())>Math.round(this.getMaxValue())){this.statusCounter=Math.round(this.getMaxValue())+" / "+Math.round(this.getMaxValue())}else{this.statusCounter=Math.round(this.getValue())+" / "+Math.round(this.getMaxValue())}return this.statusCounter}},{key:"getStatusType",value:function t(){return this.statusType}},{key:"setStatusType",value:function t(s){if(e.Type.isStringFilled(s)){this.statusType=s}}},{key:"createContainer",value:function t(){if(this.container===null){this.container=e.Dom.create("div",{props:{className:"ui-progressbar"},children:[this.getTextAfter(),this.getTextBefore(),this.getStatus(),BX.create("div",{props:{className:"ui-progressbar-track"},children:[this.getBar()]})]});this.setColor(this.color);this.setColumn(this.column);this.setSize(this.size);this.setFill(this.fill);this.setColorTrack(this.colorTrack);this.setColorBar(this.colorBar)}}},{key:"getBar",value:function t(){if(this.bar===null){this.bar=e.Dom.create("div",{props:{className:"ui-progressbar-bar"},style:{width:"".concat(this.getStatusPercent(),"%")}})}return this.bar}},{key:"update",value:function t(s){if(this.container===null){this.createContainer()}this.setValue(s);if(s>=this.maxValue){setTimeout(function(){e.Dom.addClass(this.container,"ui-progressbar-finished")}.bind(this),300);this.finished=true}else{e.Dom.removeClass(this.container,"ui-progressbar-finished");this.finished=false}this.setStatus();if(this.bar===null){this.getBar()}e.Dom.adjust(this.bar,{style:{width:"".concat(this.getStatusPercent(),"%")}})}},{key:"getContainer",value:function t(){if(this.container===null){this.createContainer()}return this.container}},{key:"renderTo",value:function t(s){if(e.Type.isDomNode(s)){return s.appendChild(this.getContainer())}return null}},{key:"destroy",value:function t(){e.Dom.remove(this.container);this.container=null;this.finished=false;this.textAfterContainer=null;this.textBeforeContainer=null;this.bar=null;for(var s in this){if(this.hasOwnProperty(s)){delete this[s]}}Object.setPrototypeOf(this,null)}}]);return t}();function g(t){if(this.container===null){this.createContainer()}this.setFill(false);this.setColor(BX.UI.ProgressBar.Color.NONE);var e=this.container.getAttribute("style"),s=!e?t:e+t;this.container.setAttribute("style",s)}babelHelpers.defineProperty(p,"Color",s);babelHelpers.defineProperty(p,"Size",i);babelHelpers.defineProperty(p,"Status",r);t.ProgressBar=p})(this.BX.UI=this.BX.UI||{},BX);
//# sourceMappingURL=progressbar.bundle.map.js